#delimit ;
capture drop scode;
cap cd "C:\Users\ejm5\Google Drive\Pillar_Pole_2014_Revision"
cap cd "C:\Users\Jordan.Becker\Desktop\GD\Pillar_Pole_2014_Revision"
log using "log\cs ccode, string to COW.log", replace;

*********************************************************************************;
*********************************************************************************;
*                                                                               *;
*   Andreas Beger                                                               *;
*   Florida State University                                                    *;
*   abeger@fsu.edu                                                              *;
*   18 Dec. 2006                                                                *;
*                                                                               *;
*   File:       cs ccode, string to COW.do                                      *;
*   Purpose:    Create a variable containing numeric COW country codes in an    *;
*               existing cross-sectional dataset with full country names.       *;
*               Covers time period from 1946 to 2004.                           *;
*   Log:        cs ccode, string to COW.log                                     *;
*                                                                               *;
*********************************************************************************;
*********************************************************************************;
*                                                                               *;
*   Notes:                                                                      *;
*   (1) Before running this do file, load the dataset, and rename the country   *;
*       name variable to "sname".                                               *;
*   (2) Variables:                                                              *;
*       scode   State Code (COW country code)                                   *;
*       sname   State Name                                                      *;
*   (3) The specific name used for state/country in a dataset could be slightly *;
*       different from the one specific here. In that case, you will either     *;
*       have to change the name used in this batch file or manually assign a    *;
*       country to that state/country in the dataset using STATA.               *;
*                                                                               *;
*********************************************************************************;
*********************************************************************************;
;
gen ccode=.;


* replace scode= if sname=="";                                                  *;

replace ccode=  2 if countryname=="United States of America";
replace ccode=  2 if countryname=="United States";
replace ccode=  2 if countryname=="USA";
replace ccode= 20 if countryname=="Canada";
replace ccode= 31 if countryname=="Bahamas";
replace ccode= 31 if countryname=="Bahamas, The";
replace ccode= 40 if countryname=="Cuba";
replace ccode= 41 if countryname=="Haiti";
replace ccode= 42 if countryname=="Dominican Republic";
replace ccode= 42 if countryname=="Dominican Rep.";
replace ccode= 51 if countryname=="Jamaica";
replace ccode= 52 if countryname=="Trinidad and Tobago";
replace ccode= 52 if countryname=="Trinidad & Tobago";
replace ccode= 52 if countryname=="Trinidad &Tobago";
replace ccode= 53 if countryname=="Barbados";
replace ccode= 54 if countryname=="Dominica";
replace ccode= 55 if countryname=="Grenada";
replace ccode= 56 if countryname=="St. Lucia";
replace ccode= 57 if countryname=="St. Vincent and the Grenadines";
replace ccode= 57 if countryname=="St. Vincent & Grens.";
replace ccode= 57 if countryname=="St. Vincent & Grenadines";
replace ccode= 57 if countryname=="St.Vincent & Grenadines";
replace ccode= 58 if countryname=="Antigua & Barbuda";
replace ccode= 58 if countryname=="Antigua and Barbuda";
replace ccode= 58 if countryname=="Antigua";
replace ccode= 60 if countryname=="St. Kitts and Nevis";
replace ccode= 60 if countryname=="St. Kitts & Nevis";
replace ccode= 70 if countryname=="Mexico";
replace ccode= 80 if countryname=="Belize";
replace ccode= 90 if countryname=="Guatemala";
replace ccode= 91 if countryname=="Honduras";
replace ccode= 92 if countryname=="El Salvador";
replace ccode= 93 if countryname=="Nicaragua";
replace ccode= 94 if countryname=="Costa Rica";
replace ccode= 95 if countryname=="Panama";
replace ccode=100 if countryname=="Colombia";
replace ccode=101 if countryname=="Venezuela";
replace ccode=101 if countryname=="Venezuela, Rep. Bol.";
replace ccode=110 if countryname=="Guyana";
replace ccode=115 if countryname=="Suriname";
replace ccode=130 if countryname=="Ecuador";
replace ccode=135 if countryname=="Peru";
replace ccode=140 if countryname=="Brazil";
replace ccode=145 if countryname=="Bolivia";
replace ccode=150 if countryname=="Paraguay";
replace ccode=155 if countryname=="Chile";
replace ccode=160 if countryname=="Argentina";
replace ccode=165 if countryname=="Uruguay";
replace ccode=200 if countryname=="United Kingdom";
replace ccode=200 if countryname=="UK";
replace ccode=205 if countryname=="Ireland";
replace ccode=210 if countryname=="Netherlands";
replace ccode=211 if countryname=="Belgium";
replace ccode=212 if countryname=="Luxembourg";
replace ccode=220 if countryname=="France";
replace ccode=221 if countryname=="Monaco";
replace ccode=223 if countryname=="Liechtenstein";
replace ccode=225 if countryname=="Switzerland";
replace ccode=230 if countryname=="Spain";
replace ccode=232 if countryname=="Andorra";
replace ccode=235 if countryname=="Portugal";
replace ccode=255 if countryname=="Germany";
replace ccode=260 if countryname=="German Federal Republic";
replace ccode=265 if countryname=="German Democratic Republic";
replace ccode=265 if countryname=="German DR";
replace ccode=290 if countryname=="Poland";
replace ccode=305 if countryname=="Austria";
replace ccode=310 if countryname=="Hungary";
replace ccode=315 if countryname=="Czechoslovakia";
replace ccode=316 if countryname=="Czech Republic";
replace ccode=316 if countryname=="Czech Rep.";
replace ccode=317 if countryname=="Slovakia";
replace ccode=317 if countryname=="Slovak Republic";
replace ccode=317 if countryname=="Slovak Rep.";
replace ccode=325 if countryname=="Italy";
replace ccode=331 if countryname=="San Marino";
replace ccode=338 if countryname=="Malta";
replace ccode=339 if countryname=="Albania";
replace ccode=343 if countryname=="Macedonia";
replace ccode=343 if countryname=="Macedonia, FYR";
replace ccode=344 if countryname=="Croatia";
replace ccode=345 if countryname=="Yugoslavia";
replace ccode=345 if countryname=="Serbia and Montenegro";
replace ccode=345 if countryname=="Serbia";
replace ccode=345 if countryname=="Yugoslavia (former)";
replace ccode=341 if countryname=="Montenegro";
replace ccode=346 if countryname=="Bosnia and Herzegovina";
replace ccode=346 if countryname=="Bosnia";
replace ccode=346 if countryname=="Bosnia-Herzegovina";
replace ccode=347 if countryname=="Kosovo";
replace ccode=349 if countryname=="Slovenia";
replace ccode=350 if countryname=="Greece";
replace ccode=352 if countryname=="Cyprus";
replace ccode=355 if countryname=="Bulgaria";
replace ccode=359 if countryname=="Moldova";
replace ccode=360 if countryname=="Romania";
replace ccode=365 if countryname=="Russia";
replace ccode=365 if countryname=="Russian Federation";
replace ccode=364 if countryname=="USSR";
replace ccode=366 if countryname=="Estonia";
replace ccode=367 if countryname=="Latvia";
replace ccode=368 if countryname=="Lithuania";
replace ccode=369 if countryname=="Ukraine";
replace ccode=370 if countryname=="Belarus";
replace ccode=371 if countryname=="Armenia";
replace ccode=372 if countryname=="Georgia";
replace ccode=373 if countryname=="Azerbaijan";
replace ccode=375 if countryname=="Finland";
replace ccode=380 if countryname=="Sweden";
replace ccode=385 if countryname=="Norway";
replace ccode=390 if countryname=="Denmark";
replace ccode=390 if countryname=="Denmark";
replace ccode=395 if countryname=="Iceland";
replace ccode=402 if countryname=="Cape Verde";
replace ccode=403 if countryname=="Sao Tome and Principe";
replace ccode=404 if countryname=="Guinea-Bissau";
replace ccode=411 if countryname=="Equatorial Guinea";
replace ccode=420 if countryname=="Gambia";
replace ccode=420 if countryname=="Gambia, The";
replace ccode=432 if countryname=="Mali";
replace ccode=433 if countryname=="Senegal";
replace ccode=434 if countryname=="Benin";
replace ccode=435 if countryname=="Mauritania";
replace ccode=436 if countryname=="Niger";
replace ccode=437 if countryname=="Ivory Coast";
replace ccode=437 if countryname=="C?te d'Ivoire";
replace ccode=437 if countryname=="Cote d'Ivoire";
replace ccode=437 if countryname=="Cote d`Ivoire";
replace ccode=437 if countryname=="Côte d’Ivoire";
replace ccode=438 if countryname=="Guinea";
replace ccode=439 if countryname=="Burkina Faso";
replace ccode=450 if countryname=="Liberia";
replace ccode=451 if countryname=="Sierra Leone";
replace ccode=452 if countryname=="Ghana";
replace ccode=461 if countryname=="Togo";
replace ccode=471 if countryname=="Cameroon";
replace ccode=475 if countryname=="Nigeria";
replace ccode=481 if countryname=="Gabon";
replace ccode=482 if countryname=="Central African Republic";
replace ccode=482 if countryname=="Central African Rep.";
replace ccode=482 if countryname=="Central African Rep";
replace ccode=483 if countryname=="Chad";
replace ccode=484 if countryname=="Congo";
replace ccode=484 if countryname=="Congo, Republic of the";
replace ccode=484 if countryname=="Congo, Republic of";
replace ccode=484 if countryname=="Congo, Rep.";
replace ccode=484 if countryname=="Congo, Rep";
replace ccode=484 if countryname=="Congo-Brazzaville";
replace ccode=484 if countryname=="Congo, Brazzaville";
replace ccode=490 if countryname=="Democratic Republic of the Congo";
replace ccode=490 if countryname=="Congo, Democratic Republic of the";
replace ccode=490 if countryname=="Congo, Democratic Republic";
replace ccode=490 if countryname=="Congo, Dem. Rep. of";
replace ccode=490 if countryname=="Congo, Dem. Rep.";
replace ccode=490 if countryname=="Congo-Kinshasa";
replace ccode=490 if countryname=="Congo, DR";
replace ccode=490 if countryname=="Zaire";
replace ccode=500 if countryname=="Uganda";
replace ccode=501 if countryname=="Kenya";
replace ccode=510 if countryname=="Tanzania";
replace ccode=511 if countryname=="Zanzibar";
replace ccode=516 if countryname=="Burundi";
replace ccode=517 if countryname=="Rwanda";
replace ccode=520 if countryname=="Somalia";
replace ccode=522 if countryname=="Djibouti";
replace ccode=530 if countryname=="Ethiopia";
replace ccode=531 if countryname=="Eritrea";
replace ccode=540 if countryname=="Angola";
replace ccode=541 if countryname=="Mozambique";
replace ccode=551 if countryname=="Zambia";
replace ccode=552 if countryname=="Zimbabwe";
replace ccode=553 if countryname=="Malawi";
replace ccode=560 if countryname=="South Africa";
replace ccode=565 if countryname=="Namibia";
replace ccode=570 if countryname=="Lesotho";
replace ccode=571 if countryname=="Botswana";
replace ccode=572 if countryname=="Swaziland";
replace ccode=580 if countryname=="Madagascar";
replace ccode=581 if countryname=="Comoros";
replace ccode=590 if countryname=="Mauritius";
replace ccode=591 if countryname=="Seychelles";
replace ccode=600 if countryname=="Morocco";
replace ccode=615 if countryname=="Algeria";
replace ccode=616 if countryname=="Tunisia";
replace ccode=620 if countryname=="Libya";
replace ccode=625 if countryname=="Sudan";
replace ccode=626 if countryname=="South Sudan";
replace ccode=630 if countryname=="Iran";
replace ccode=630 if countryname=="Iran, Islamic Republic";
replace ccode=630 if countryname=="Iran, Ismalic Rep.";
replace ccode=630 if countryname=="Iran, Ismalic Rep";
replace ccode=640 if countryname=="Turkey";
replace ccode=640 if countryname=="Türkiye";
replace ccode=645 if countryname=="Iraq";
replace ccode=651 if countryname=="Egypt";
replace ccode=651 if countryname=="Egypt, Arab Republic";
replace ccode=651 if countryname=="Egypt, Arab Rep.";
replace ccode=652 if countryname=="Syria";
replace ccode=652 if countryname=="Syrian Arab Republic";
replace ccode=660 if countryname=="Lebanon";
replace ccode=663 if countryname=="Jordan";
replace ccode=666 if countryname=="Israel";
replace ccode=670 if countryname=="Saudi Arabia";
replace ccode=678 if countryname=="Yemen Arab Republic";
replace ccode=678 if countryname=="Yemen, North";
replace ccode=679 if countryname=="Yemen";
replace ccode=679 if countryname=="Yemen, Rep.";
replace ccode=679 if countryname=="Yemen, Republic of";
replace ccode=680 if countryname=="Yemen People's Republic";
replace ccode=690 if countryname=="Kuwait";
replace ccode=692 if countryname=="Bahrain";
replace ccode=694 if countryname=="Qatar";
replace ccode=696 if countryname=="United Arab Emirates";
replace ccode=696 if countryname=="UAE";
replace ccode=698 if countryname=="Oman";
replace ccode=700 if countryname=="Afghanistan";
replace ccode=701 if countryname=="Turkmenistan";
replace ccode=702 if countryname=="Tajikistan";
replace ccode=703 if countryname=="Kyrgyzstan";
replace ccode=703 if countryname=="Kyrgyz Republic";
replace ccode=704 if countryname=="Uzbekistan";
replace ccode=705 if countryname=="Kazakhstan";
replace ccode=710 if countryname=="China";
replace ccode=710 if countryname=="China, People's Republic";
replace ccode=710 if countryname=="China, People's Rep.";
replace ccode=710 if countryname=="China, People's Rep";
replace ccode=710 if countryname=="China, PRC";
replace ccode=710 if countryname=="China,P.R.: Mainland";
replace ccode=710 if countryname=="China, P.R.";
replace ccode=712 if countryname=="Mongolia";
replace ccode=713 if countryname=="Taiwan";
replace ccode=713 if countryname=="Taiwan, China";
replace ccode=730 if countryname=="Korea";
replace ccode=731 if countryname=="North Korea";
replace ccode=731 if countryname=="Korea, Democratic Republic";
replace ccode=731 if countryname=="Korea, Dem. Rep.";
replace ccode=731 if countryname=="Korea, North";
replace ccode=732 if countryname=="South Korea";
replace ccode=732 if countryname=="Korea";
replace ccode=732 if countryname=="Korea, Republic of";
replace ccode=732 if countryname=="Republic of Korea";
replace ccode=732 if countryname=="Korea, Rep.";
replace ccode=732 if countryname=="Korea, South";
replace ccode=740 if countryname=="Japan";
replace ccode=750 if countryname=="India";
replace ccode=760 if countryname=="Bhutan";
replace ccode=770 if countryname=="Pakistan";
replace ccode=771 if countryname=="Bangladesh";
replace ccode=775 if countryname=="Myanmar";
replace ccode=780 if countryname=="Sri Lanka";
replace ccode=781 if countryname=="Maldives";
replace ccode=790 if countryname=="Nepal";
replace ccode=800 if countryname=="Thailand";
replace ccode=811 if countryname=="Cambodia";
replace ccode=812 if countryname=="Laos";
replace ccode=812 if countryname=="Lao People's Dem.Rep";
replace ccode=816 if countryname=="Vietnam";
replace ccode=817 if countryname=="Republic of Vietnam";
replace ccode=817 if countryname=="Vietnam, Republic of";
replace ccode=817 if countryname=="Viet Nam";
replace ccode=820 if countryname=="Malaysia";
replace ccode=830 if countryname=="Singapore";
replace ccode=835 if countryname=="Brunei";
replace ccode=840 if countryname=="Philippines";
replace ccode=850 if countryname=="Indonesia";
replace ccode=860 if countryname=="East Timor";
replace ccode=860 if countryname=="Timor Leste";
replace ccode=900 if countryname=="Australia";
replace ccode=910 if countryname=="Papua New Guinea";
replace ccode=920 if countryname=="New Zealand";
replace ccode=935 if countryname=="Vanuatu";
replace ccode=940 if countryname=="Solomon Islands";
replace ccode=946 if countryname=="Kiribati";
replace ccode=947 if countryname=="Tuvalu";
replace ccode=950 if countryname=="Fiji";
replace ccode=955 if countryname=="Tonga";
replace ccode=970 if countryname=="Nauru";
replace ccode=983 if countryname=="Marshall Islands";
replace ccode=986 if countryname=="Palau";
replace ccode=987 if countryname=="Federated States of Micronesia";
replace ccode=987 if countryname=="Micronesia, Fed. Sts.";
replace ccode=990 if countryname=="Samoa";

;end
